﻿<%
Sa.Extends("checkAction")
'系统设置类
Class systemAction
	
	'''构造
	Private Sub Class_Initialize()
		check.ForAjax()
	End Sub
	
	'''析构
	Private Sub Class_Terminate()
	End Sub
	
	'''显示URL规则
	Public Sub url()
		If IsN(G_Rule) Then
			Set G_Rule = Server.CreateObject("Scripting.Dictionary")
			G_Rule.RemoveAll
		End If
	End Sub
	
	'''添加URL规则
	Public Sub ruleadd()
		Sa.Show()
	End Sub
	
	'''修改URL规则
	Public Sub ruleedt()
		Dim t_key : t_key = Clng(G("id:n:0"))
		If G_Rule.Exists(t_key) Then
			Sa.Dim("S_name") : S_name = G_Rule(t_key)(0)
			Sa.Dim("S_id") : S_id = t_key
			Sa.Dim("S_ruleo") : S_ruleo = G_Rule(t_key)(1)
			Sa.Dim("S_urlo") : S_urlo = G_Rule(t_key)(2)
			Sa.Dim("S_rulet") : S_rulet = G_Rule(t_key)(3)
			Sa.Dim("S_urlt") : S_urlt = G_Rule(t_key)(4)
		Else
			Sa.ErrorE("未发现该URL规则!")
		End If
	End Sub
	
	'''保存URL规则
	Public Sub rulesave()
		Sa.Use("Fso")
		Sa.Use("Tool")
		If IsN(P("id")) Then
			Sa.ErrorE("排序定位ID不能为空!")
		End If
		Dim t_res : t_res = False
		Select Case Lcase(P("action"))
		Case "add"
			t_res = Tool.AddUrlRule(P("id"), P("name"), P("ruleo"), P("urlo"), P("rulet"), P("urlt"))
			Select Case Cstr(t_res)
			Case "0"
				Sa.Error("排序定位ID不能重复!")
			Case "1"
				Sa.JumpUrl = "/?g=admin&m=system&a=url"
				Sa.Success("添加成功!")
			Case "2"
				Sa.Error("在备份Rule文件时发生错误!")
			Case "3"
				Sa.Error("在创建新的Rule文件时发生错误!")
			Case Else
				Sa.Error("出现未知的状态值:" & t_res)
			End Select
		Case "edt"
			t_res = Tool.EdtUrlRule(Clng(P("oid:n")), P("id"), P("name"), P("ruleo"), P("urlo"), P("rulet"), P("urlt"))
			Select Case Cstr(t_res)
			Case "0"
				Sa.Error("未发现该URL规则!")
			Case "1"
				Sa.JumpUrl = "/?g=admin&m=system&a=url"
				Sa.Success("修改成功!")
			Case "2"
				Sa.Error("在备份Rule文件时发生错误!")
			Case "3"
				Sa.Error("在创建新的Rule文件时发生错误!")
			Case Else
				Sa.Error("出现未知的状态值:" & t_res)
			End Select
		Case "del"
		Case Else
		End Select
	End Sub
	
	'''刷新环境缓存
	Public Sub refapp()
		Sa.Use("Fso")
		Sa.Use("Tool")
		If Tool.RefreshApp() = 1 Then
			Call check.W200("环境缓存刷新成功!", "")
		Else
			check.W300("环境缓存刷新失败!")
		End If
	End Sub
	
	'''刷新Htaccess
	Public Sub htaccess()
		Sa.Use("Fso")
		Sa.Use("Tool")
		Dim t_res : t_res = Tool.BulidHtaccess()
		Select Case Cstr(t_res)
		Case "0"
			check.W300("URL不存在,无需建立Htaccess!")
		Case "1"
			Call check.W200("Htaccess文件刷新成功!", "")
		Case "2"
			check.W300("Htaccess文件创建失败!")
		Case "3"
			check.W300("Htaccess文件备份失败!")
		Case Else
			check.W300("未指定的类型:"&t_res)
		End Select
	End Sub
	
	'''创建/更新入口文件
	Public Sub enter()
		Sa.Use("Fso")
		Sa.Use("Tool")
		If Tool.BuildEnter() = 1 Then
			Call check.W200("入口文件刷新成功!", "")
		Else
			check.W300("入口文件刷新失败!")
		End If
	End Sub
	
	'''清除运行缓存
	Public Sub clear()
		Sa.Use("Fso")
		Sa.Use("Tool")
		If Tool.ClearCache() = 1 Then
			Call check.W200("运行缓存清除成功!", "")
		Else
			check.W300("运行缓存清除失败!")
		End If
	End Sub
	
	'''系统设置
	Public Sub config()
	End Sub
End Class
%>